<?php

/**
 * This is the model class for table "stuinteitem".
 *
 * The followings are the available columns in table 'stuinteitem':
 * @property integer $stuInteItemId
 * @property integer $uId
 * @property integer $inteItemId
 * @property string $name
 * @property string $module
 * @property string $content
 * @property string $term
 * @property string $detail
 * @property double $credit
 * @property string $addtime
 * @property integer $condition
 *
 * The followings are the available model relations:
 * @property Inteitem $inteItem
 * @property User $u
 */
class Stuinteitem extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Stuinteitem the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'stuinteitem';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('uId, inteItemId, name, module, content, term, detail, credit, addtime, condition', 'required'),
			array('uId, inteItemId, condition', 'numerical', 'integerOnly'=>true),
			array('credit', 'numerical'),
			array('name, module, content, term', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('stuInteItemId, uId, inteItemId, name, module, content, term, detail, credit, addtime, condition', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inteItem' => array(self::BELONGS_TO, 'Inteitem', 'inteItemId'),
			'u' => array(self::BELONGS_TO, 'User', 'uId'),
			'stuinfo' => array(self::BELONGS_TO, 'Stuinfo', array('uId'=>'uId')),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'stuInteItemId' => 'Stu Inte Item',
			'uId' => 'U',
			'inteItemId' => 'Inte Item',
			'name' => 'Name',
			'module' => 'Module',
			'content' => 'Content',
			'term' => 'Term',
			'detail' => 'Detail',
			'credit' => 'Credit',
			'addtime' => 'Addtime',
			'condition' => 'Condition',
		);
	}
   public function  getShortLabels(){
	   return array(
			
			'name' => '条目名称',
			'module' => '模块',
			'content' => '内容',
			'term' => '条目',
			'detail' => '详情',
			'credit' => '学分',
			'addtime' => '添加时间',
			'condition' => '状态',
		);
	   
   }
   public function getShortData(){
	   
	    $data = array();
		$labels = $this->getShortLabels();
		foreach($labels as $key => $value){
			// 1 ---- 未审核 2 ---- 未通过 3 --- 已通过
			if($key == 'condition'){
				if($this->condition == '1')
					$data[$value] = '未审核';
				else if($this->condition == '2')
					$data[$value] = '未通过';
				else if($this->condition == '3')
				    $data[$value] = '已通过';
				continue;
			}
			$data[$value] = $this->$key;
			
		}
		return $data;
	   
	   
	   
   }
	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('stuInteItemId',$this->stuInteItemId);
		$criteria->compare('uId',$this->uId);
		$criteria->compare('inteItemId',$this->inteItemId);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('module',$this->module,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('term',$this->term,true);
		$criteria->compare('detail',$this->detail,true);
		$criteria->compare('credit',$this->credit);
		$criteria->compare('addtime',$this->addtime,true);
		$criteria->compare('condition',$this->condition);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}